package com.gym.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gym.dao.GoodsDao;
import com.gym.pojo.Goods;
import com.gym.pojo.Train;
import com.gym.service.GoodsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {
    @Resource
    private GoodsDao goodsDao;

    @Override
    public boolean insertjh(Goods goods) {
        return goodsDao.insertjh(goods)>0;
    }

    @Override
    public boolean selectysp(String goodsname) {
        return goodsDao.selectysp(goodsname)>0;
    }

    @Override
    public boolean selectzkc(int goodsId,int totalstock) {
        return goodsDao.selectzkc(goodsId,totalstock)>0;
    }

    @Override
    public boolean selectsl(int goodsId,int goodsamount) {
        return goodsDao.selectsl(goodsId,goodsamount)>0;
    }

    @Override
    public List<Goods> selectzj() {
        return goodsDao.selectcp(null);
    }


    @Override
    public PageInfo<Goods> selectcp(String goodsname,int index,int size) {
        PageHelper.startPage(index, size);
        PageInfo<Goods> page =new PageInfo<Goods>(goodsDao.selectcp(goodsname),5);
        return page;
    }

    @Override
    public boolean updatejhj(int totalstock, int goodsId) {
        return goodsDao.updatejhj(totalstock,goodsId)>0;
    }

    @Override
    public boolean updatezj(int goodsId, int goodsamount) {
        return goodsDao.updatezj(goodsId,goodsamount)>0;
    }

    @Override
    public boolean deletesc(int goodsId) {
        return goodsDao.deletesc(goodsId)>0;
    }

    @Override
    public boolean updatejj(int totalstock, int goodsId, int goodsamount) {
        return goodsDao.updatejj(totalstock,goodsId,goodsamount)>0;
    }
}
